########################################################
# This application is used for user login verification
# The main functions are as follows:
# - The user enters username and password, and then submit
# - If user doesn't exist or password is incorrect, display error message
# - Wrong three times, exit the application
# - After successful verification, the login information will be displayed
########################################################

import sys

# init var
username = "chenhaolin"
password = "123456"
wrongTimes = 3

# userAuth is used for veraficate your informations


def userAuth(user, passwd):
    if user != username or passwd != password:
        global wrongTimes
        wrongTimes -= 1
        if wrongTimes == 0:
            print("You input wrong information three times, pls take a break first!")
        else:
            print("You entered the wrong username or password! Please check it -_-!")
    else:
        print("Welcome to here, Please enjoy it ^_^")
        sys.exit()

# userInput is used for take your informations


def userInput():
    user = input('Enter your username: ')
    passwd = input('Enter your password: ')
    return user, passwd


def main():
    while wrongTimes:
        user, passwd = userInput()
        userAuth(user, passwd)


if __name__ == '__main__':
    main()


# 总体来说，完成的不错，不过wrongTimes是不是可以作为一个全局变量呢，而且作为一个判断条件，这个命名方式，一开始等于0，后来判断有没有到3，时不常更好一些
